package com.bjpowernode.springboot;

import com.bjpowernode.springboot.service.StudentService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Ch13SpringbootJava1Application {

	/**
	 * Springboot程序启动后，返回值是ConfigurableApplicationContext，它也是一个Spring容器
	 * 它其实相当于原来Spring容器的启动容器ClasspathXmlApplicationContext
	 * */
	public static void main(String[] args) {
		//获取Springboot容器
		ConfigurableApplicationContext applicationContext=
				SpringApplication.run(Ch13SpringbootJava1Application.class, args);

		//从springboot容器中获取指定的bean对象
		StudentService studentService=(StudentService)applicationContext.getBean("studentServiceImpl");

		//调用业务方法
		String sayHello=studentService.sayHello();
		System.out.println(sayHello);
	}

}
